home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 05 / 6 / DISK0564.ZIP / SOURCE.ARC / UPDATE.C < prev    next >
C/C++ Source or Header  |  1988-07-09  |  2KB  |  56 lines

  1. /* this program sets the date and time of one or more files to the
  2.    current system date and time */
  3. /* for MSDOS Version 2 or higher */
  4. /* usage: update file1 file2 ... */
  5. /* file name can be ambiguous */
  6. /* for Aztec C86 v. 3.20e */
  7. /* by Jon Dart, 29-Mar-1986 */
  8.  
  9. #include "stdio.h"
  10. #include "fixpath.h"
  11. #include "sgtty.h"
  12. #include "ctype.h"
  13. #include "truth.h"
  14. #include "ascii.h"
  15.  
  16. #define PATHSIZE 128
  17.  
  18. extern char *malloc();
  19.  
  20. main(argc,argv)
  21. int argc; char *argv[];
  22. {
  23.     char *sp,*lip,*fn, *fn2;
  24.     int n,type,attrib;
  25.  
  26.     sp = malloc(PATHSIZE);
  27.     lip = malloc(PATHSIZE);
  28.     fn = malloc(PATHSIZE);
  29.     fn2 = malloc(PATHSIZE);
  30.     if (argc<=1) {
  31.         fprintf(stderr,"Update -- sets the date and time of one or more\n");
  32.         fprintf(stderr,"          files to the current date and time.\n\n");
  33.         fprintf(stderr,"by Jon Dart ... Version 1.0 (29-Mar-86)\n\n");
  34.         fprintf(stderr,"Usage:\n    update file1 file2 ....\n");
  35.         fprintf(stderr,"    (file names can be ambiguous)\n");
  36.         exit(1);
  37.     }
  38.     for (n=1;n<argc;n++) {
  39.         type = fixpath(argv[n],sp,lip);
  40.         if (getfirst(sp,0x21,fn,&attrib)) {
  41.             strcpy(fn2,lip);
  42.             strcat(fn2,fn);
  43.             utime(fn2,0); /* update time for 1 file */
  44.             while (getnext(fn,&attrib)) {
  45.                 strcpy(fn2,lip);
  46.                 strcat(fn2,fn);
  47.                 utime(fn2,0);
  48.             }
  49.         }
  50.         else {
  51.             fprintf(stderr,"%s%s\n","Error - can't find: ",argv[n]);
  52.         }
  53.     }
  54. }
  55.  
  56.